import java.util.ArrayList;
import java.util.Iterator;
import java.util.ListIterator;

public class demo {
    public static void main(String[] args) {
        Student s1 = new Student("刘德华",22);
        Student s2 = new Student("梁朝伟",24);
        Student s3 = new Student("吴彦祖",26);

        ArrayList<Student> arrayList = new ArrayList<>();
        arrayList.add(s1);
        arrayList.add(s2);
        arrayList.add(s3);

//        ListIterator<Student> iterator = arrayList.listIterator(arrayList.size()); // 相当于把迭代器插入到 size() 位置的前面. 从这里开始遍历
//        while (iterator.hasPrevious()) {
//            System.out.println(iterator.previous());
//        }

        ListIterator<Student> iterator1 = arrayList.listIterator(2); //表示把迭代器插入到1位置之前.
        while (iterator1.hasNext()) {
            System.out.println(iterator1.next());
        }
    }
}


